<?php
/*
Module:		dddate
Version:	20071128a-DAT
File:		require.php
*/
function dddate($date)
{
global $CONFIG;
$Today="";
if ($date==0)
   {
   $date=date("d.n.Y",time());
   $Today="Today is ";
   }
$array = explode('.', $date);
$Day=intval( $array[0]);
$Month=intval( $array[1]);
$Year=intval( $array[2]);
if (($Year<=100)&&(strlen($Year)<=2))
{
if ($Year<=30) $Year=$Year+2000;
else $Year=$Year+1900;
}
if (!checkdate($Month,$Day,$Year)) return $CONFIG['fehler2'];
$ftag="";

if ($Month==1) $day=0;
if ($Month==2) $day=31;
if ($Month==3) $day=31+28;
if ($Month==4) $day=31+28+31;
if ($Month==5) $day=31+28+31+30;
if ($Month==6) $day=31+28+31+30+31;
if ($Month==7) $day=31+28+31+30+31+30;
if ($Month==8) $day=31+28+31+30+31+30+31;
if ($Month==9) $day=31+28+31+30+31+30+31+31;
if ($Month==10) $day=31+28+31+30+31+30+31+31+30;
if ($Month==11) $day=31+28+31+30+31+30+31+31+30+31;
if ($Month==12) $day=31+28+31+30+31+30+31+31+30+31+30;
$t2=$Month;
$day=$day+$Day;
$temp=$day-(5*floor($day/5));

if ($temp==1) $wtag="Sweetmorn";
if ($temp==2) $wtag="Boomtime";
if ($temp==3) $wtag="Pungenday";
if ($temp==4) $wtag="Prickle-Prickle";
if ($temp==0) $wtag="Setting Orange";
if ($day<=73) $Month="Chaos";
else if ($day<=2*73)
        {
        $Month="Discord";
        $day=$day-73;
        }
else if ($day<=3*73)
        {
        $Month="Confusion";
        $day=$day-(2*73);
        }
else if ($day<=4*73)
        {
        $Month="Bureaucracy";
        $day=$day-(3*73);
        }
else
        {
        $Month="Aftermath";
        $day=$day-(4*73);
        }
$th="th";
if (($day==1)||($day==21)||($day==31)||($day==41)||($day==51)||($day==61)||($day==71)) $th="st";
if (($day==2)||($day==22)||($day==32)||($day==42)||($day==52)||($day==62)||($day==72)) $th="nd";
if (($day==3)||($day==23)||($day==33)||($day==43)||($day==53)||($day==63)||($day==73)) $th="rd";
if (($day==5)&&($Month=="Chaos")) $ftag=", !MUNGDAY!";
if (($day==5)&&($Month=="Discord")) $ftag=", !MOJODAY!";
if (($day==5)&&($Month=="Confusion")) $ftag=", !SYADAY!";
if (($day==5)&&($Month=="Bureaucracy")) $ftag=", !ZARADAY!";
if (($day==5)&&($Month=="Aftermath")) $ftag=", !MALADAY!";
if (($day==50)&&($Month=="Chaos")) $ftag=", !Chaoflux!";
if (($day==50)&&($Month=="Discord")) $ftag=", !Discoflux!";
if (($day==50)&&($Month=="Confusion")) $ftag=", !Confuflux!";
if (($day==50)&&($Month=="Bureaucracy")) $ftag=", !Bureflux!";
if (($day==50)&&($Month=="Aftermath")) $ftag=", !Afflux!";
if (($t2==2)&&($Day==29)) return $Today."St. Tib's Day in the YOLD ".($Year+1166);
else
        {
        return $Today.$wtag.", the ".$day.$th." day of ".$Month." in the YOLD ".($Year+1166).$ftag;
        }
}

?>
